<?php
/**
 * Get tags with keywords
 * Send an Array of String containing the corresponding tags
 *
 * If an error occurend, send an object with:
 * - error_type: (string) type of error, mainly 'connection'
 * - error: (string) the error
 */
require_once("../include/setup.php");
require_once(CONTROLLER_PATH.'mikubook.controller.php');

if (!empty($_REQUEST['login']) && !empty($_REQUEST['password'])) {
	Mikubook_Video_Controller::$LOGIN = $_REQUEST['login'];
	Mikubook_Video_Controller::$PASSWORD = $_REQUEST['password'];
}

$tags = array();
if (!empty($_GET['tag'])) {
	$c = new Mikubook_Video_Controller();
	$tags = $c->getTags($_GET['tag']);
	$c->close();
	
	if (!$c->connected) {
	$tags = array(
		'error_type' => 'connection',
		'error' => $c->error_connection
	);
}

}
echo json_encode($tags);
?>